/**
 * @param {string} s
 * @return {boolean}
 */
var isValid = function(s) {
    let stack = []
    // 左括号入栈
    for (let i = 0; i< s.length; i++) {
        if (s[i] == '{' || s[i] == '[' || s[i] == '(' ) {
            stack.push(s[i])
        }
        if (s[i] == '}' || s[i] == ']' || s[i] == ')') {
            if (s[i] == '}') {
                let temp = stack.pop()
                if (temp != '{') {
                    return false
                }
            }
            if (s[i] == ']') {
                let temp = stack.pop()
                if (temp != '[') {
                    return false
                }
            }
            if (s[i] == ')') {
                let temp = stack.pop()
                if (temp != '(') {
                    return false
                }
            }
        }

    }
    if (stack.length != 0) return false
    return true

};
let s = "()"
console.log(isValid(s))